<template>
  <div class="aside">
    <h4>草稿箱（{{$store.state.draft.post.length}}）</h4>
    <div class="list">
      <div class="item" v-for="(info,index) in $store.state.draft.post" :key="index">
        <p @click="read(index)">{{info.title}}</p>
        <div class="info">
          <span class="times">{{info.time}}</span>
          <span>
            <i class="iconfont icon-bianji1" @click="read(index)"></i>
            <i class="iconfont icon-lajitong" @click="deleteData(index)"></i>
          </span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  methods: {
    deleteData(index) {
      this.$store.commit("draft/delDraft", index);
    },
    read(index) {
      this.$emit("readNum", index);
    },
  },
};
</script>

<style lang="less" scoped>
.aside {
  width: 225px;
  border: 1px solid #ddd;
  padding: 10px;
  h4 {
    color: #666;
    font-weight: 400;
    margin-bottom: 10px;
  }
  .item {
    margin: 5px 0;
    p {
      font-size: 14px;
      cursor: pointer;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      &:hover {
        color: #ffa500;
        text-decoration: underline;
      }
    }
    .info {
      font-size: 14px;
      color: #999;
      display: flex;
      justify-content: space-between;
      margin: 5px 0;
      i {
        color: #333;
        font-size: 16px;
        cursor: pointer;
        margin: 0 3px;
      }
    }
  }
}
</style>